package org.andy.kmap;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;


public class CourseServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

        Gson gson = new Gson();
        CourseMap map = new CourseMap();

        map.addEdge(new Course("计算机硬件与集成"), new Course("计算机网络基础与应用"));
        map.addEdge(new Course("计算机硬件与集成"), new Course("大学计算机基础"));
        map.addEdge(new Course("多媒体技术实践"), new Course("大学计算机基础"));
        map.addEdge(new Course("计算机网络基础与应用"), new Course("计算机硬件与集成"));
        map.addEdge(new Course("计算机网络基础与应用"), new Course("大学计算机基础"));
        map.addEdge(new Course("计算机网络基础与应用"), new Course("信息系统分析与设计"));
        map.addEdge(new Course("计算机网络基础与应用"), new Course("离散数学"));

        String json = gson.toJson(map);

        response.setContentType("application/json;charset=UTF-8");
        response.setHeader("Cache-Control", "no-cache");
        response.getWriter().write(json);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    }
}
